package arm.dic.bean;

import arm.dic.entity.DicMetricType;
import arm.common.manager.TableManager;
import arm.db.tools.DBManager;

public class DicMetricTypeBean
{
    private DicMetricType metricType;
    private TableManager<DicMetricType> tableManager;

    public DicMetricType getMetricType() {
        return metricType;
    }

    public void setMetricType(DicMetricType metricType) {
        this.metricType = metricType;
    }

    public String create()
    {
        metricType = new DicMetricType();
        return "editDicMetricType";
    }


    public String save()
    {
        DBManager.saveOrUpdate(getMetricType());
        return viewTable();
    }

    public String edit()
    {
        setMetricType(getTableManager().getSelectedObj());
        return "editDicMetricType";
    }

    public String cancel()
    {
        return viewTable();
    }

    public String viewTable ()
    {
        getTableManager().readFromDB();
        return "viewDicMetricTypeTable" ;
    }

    public TableManager<DicMetricType> getTableManager() {
        if (tableManager == null)
        {
            tableManager = new TableManager<DicMetricType>(DicMetricType.class);
        }
        return tableManager;
    }

    public void setTableManager(TableManager<DicMetricType> tableManager) {
        this.tableManager = tableManager;
    }

    public void delete ()
    {
        DBManager.delete(getTableManager().getSelectedObj());
        getTableManager().readFromDB();
    }


}


